package com.example.databinding_demo.mvvm;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;

import com.example.databinding_demo.R;
import com.example.databinding_demo.databinding.ActivityMvvmBinding;

public class MVVMActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMvvmBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_mvvm);
        // viewModel初始化
        MvvmViewModel mvvmViewModel = new MvvmViewModel(getApplication());
        binding.setViewModel(mvvmViewModel);
    }
}